<template>
 <div>
     <div class="modal-backdrop">
       <div class="modal" >
         <div class="modal-header">
           <div class="hospSetUpdate">修改医院设置</div>
         </div>
         <div class="modal-body">
           <el-form ref="form" :model="hospitalSet" label-width="100px">
             <el-form-item  label="医院名称" prop="hosname" :rules="[{ required: true, message: '请输入医院名称', trigger: 'blur' }]">
               <el-input v-model="hospitalSet.hosname" placeholder="医院名称"/>
             </el-form-item>
             <el-form-item style="margin-top: 50px" label="医院编号" prop="hoscode" :rules="[{ required: true, message: '请输入医院编号', trigger: 'blur' }]">
               <el-input  v-model="hospitalSet.hoscode" placeholder="医院编号"/>
             </el-form-item>
             <el-form-item style="margin-top: 50px" label="api基础路径" prop="apiUrl" :rules="[{ required: true, message: '请输入api基础路径', trigger: 'blur' }]">
               <el-input  v-model="hospitalSet.apiUrl" placeholder="api基础路径"/>
             </el-form-item>
             <el-form-item style="margin-top: 50px" label="联系人名称" prop="contactsName" :rules="[{ required: true, message: '请输入联系人名称', trigger: 'blur' }]">
               <el-input  v-model="hospitalSet.contactsName" placeholder="联系人名称"/>
             </el-form-item>
             <el-form-item style="margin-top: 50px" label="联系人手机" prop="contactsPhone"
                           :rules="[{ required: true, message: '请输入联系人电话', trigger: 'blur' }, { type: 'number', message: '联系人电话必须为数字值', trigger: ['blur'] }]">
               <el-input  v-model.number="hospitalSet.contactsPhone" placeholder="联系人手机"/>
             </el-form-item>
             <el-form-item label="状态">
               <el-radio v-model="hospitalSet.status" :label="1">可用</el-radio>
               <el-radio v-model="hospitalSet.status" :label="0">不可用</el-radio>
             </el-form-item>
           </el-form>
         </div>
         <div class="modal-footer">
           <button type="button" class="btn-close" @click="closeSelf">关闭</button>
           <button type="button" class="btn-confirm" @click="updateHospSet()" >确认</button>
         </div>
       </div>
     </div>
  </div>
</template>

<script>
import hospSet from "@/api/hospSet";
export default {
  name: "Update",
  props:['hospitalSet'],
  data() {
    return {
      show: false,   // 是否显示模态框
    };
  },
  methods: {
    //修改医院设置信息
    updateHospSet(){
      hospSet.updateHospitalSet(this.hospitalSet)
        .then(request =>{
          if(request.code ===200 && request.message ==='成功') {
            this.$message({
              message: '恭喜你，修改成功，id为' + this.hospitalSet.id + '的医院已经被修改了',
              type: 'success'
            });
            this.$emit("closeme");
            this.$emit("getList", this.hospitalSet.current, this.hospitalSet.size);
          }
        })
        .catch(error => {
          this.$message.error('抱歉，修改医院设置信息失败，请与管理员联系');
        })
    },
    closeSelf() {
      this.$emit("closeme");
    }
  }
}
</script>

<style >
@keyframes slideIn {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slideOut {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(0);
  }
}

.slide-enter-active {
  animation: slideIn .5s;
}

.slide-leave-active {
  animation: slideOut .5s;
}

::-webkit-scrollbar {
  width: 0 !important;
}

::-webkit-scrollbar {
  width: 0 !important;height: 0;
}
.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(0,0,0,.3);
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal {
  background-color: #fff;
  box-shadow: 2px 2px 20px 1px;
  overflow-x:auto;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  width: 700px;
}
.modal-header {
  border-bottom: 1px solid #eee;
  color: #313131;
  justify-content: space-between;
  padding: 15px;
  display: flex;
}
.modal-footer {
  border-top: 1px solid #eee;
  justify-content: flex-end;
  padding: 15px;
  display: flex;
}
.modal-body {
  position: relative;
  padding: 20px 10px;
}
.btn-close, .btn-confirm {
  border-radius: 8px;
  margin-left:16px;
  width:56px;
  height: 36px;
  border:none;
  cursor: pointer;
}
.btn-close {
  color: #313131;
  background-color:transparent;
}
.btn-confirm {
  color: #fff;
  background-color: #2d8cf0;
}
.hospSetUpdate {
  color: #000000;
  font-family: "Helvetica Neue", serif;
  font-size: 30px;
  line-height: 50px;
  margin-left: 50px;
  text-align: center;
  align-items: center;
}
</style>

